package com.changgou.config.controller;

import com.changgou.config.pojo.Areas;
import com.changgou.config.service.AreasService;
import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/areas")
public class AreasController {


    @Autowired
    private AreasService areasService;

    /***
     * 根据城市ID查询
     * @param cityid
     * @return
     */
    @GetMapping("/{cityid}")
    public Result findById(@PathVariable String cityid){
        try {
            List<Areas> cities = areasService.findById(cityid);
            return new Result(true, StatusCode.OK,"查询成功",cities);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, StatusCode.ERROR,"查询失败");
        }
    }
}
